#include "snprintf.h"
#include <stdio.h>

int __vsnprintf(char* dst,int size,const char* fmt,va_list ap)
{
	if(size<=0)
		return 0;
#ifdef _WIN32
	int rc=_vsnprintf(dst,size,fmt,ap);
#else
	int rc=vsnprintf(dst,size,fmt,ap);
#endif
	if(rc<0 || rc>=size)
		rc=size-1;
	dst[rc]=0;
	return rc;
}


int __snprintf(char* dst,int size,const char* fmt,...)
{
	va_list ap;
	va_start(ap,fmt);
	int rc=__vsnprintf(dst,size,fmt,ap);
	va_end(ap);
	return rc;
}
